<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>七宫格布局--浮动</title>
    <style>
        * {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }
        .container {
            position: absolute;
            height: 100%;
            left:0;
            top:0;
            right:0;
            bottom:0;
        }
        /* 行内元素不能给高度 */
        .container .item {
            float: left;
            height: 100px;
            width: 25%;
            position: relative;
            background-color: pink;
            border: 1px solid black;
            text-align: center;
            line-height: 100px;
        }
        .container :nth-child(2),:nth-child(5){
            margin-left: 50%;
        }
        .container :nth-child(3) {
            width: 50%;
            margin: 0 25%;
        }
        .container :nth-child(6) {
            margin-left: 25%;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="item">1</div>
        <div class="item">2</div>
        <div class="item">3</div>
        <div class="item">4</div>
        <div class="item">5</div>
        <div class="item">6</div>
        <div class="item">7</div>
    </div>
</body>
</html>